package com.ty.day1;

/**
 * Created by IntelliJ IDEA.
 *
 * @author : txy
 * @create : 2023/11/22 14:22
 */
public class Three {
    public static void main(String[] args) {
        String name = " 杨幂冲击波杨幂，冲击波，冲击波66，冲击波12";
        /*//去空格
        name = name.trim();
        //判断书否以”杨“开头
        boolean start = name.startsWith("杨");
        System.out.println(start);
        //是否以”幂“结尾
        boolean end = name.endsWith("幂");
        System.out.println(end);
        //输出字符串长度
        System.out.println(name.length());*/
        int count =0,index=0;
        while (true) {
            index = name.indexOf("冲击波", index);
            if (index!=-1){
                count++;
                index=index+"冲击波".length()+1;
            }else {
                break;
            }
        }
        System.out.println(count);
    }
}
